<!-- 设置面包屑 -->
#set($breadcrumbs = [{"name":"用户管理","url":"$!{base}/user/list"},{"name":"用户列表"}])
<!-- 设置功能描述 -->
#set($feature = {"major":"用户管理","minor":"用户列表"}) 
<!-- 设置导航高亮 -->
#set($subList = "user_list") 
<table class="table table-striped table-bordered table-hover">
	<thead>
		<tr>
			<th colspan="6">
				<div class="row">
					<div class="col-md-3 ">
						<form action="$!{base}/user/search" method="post" class="search-form">
							<div class="input-group">
								<span class="input-group-addon"> 关键词 </span> 
								<input class="form-control search-query" type="text" name="key" value="" data-type="reg" data-reg="/^[\u4e00-\u9fa5\d\w]{1,}$/" data-default="Search..." data-error="请输入搜索关键词" placeholder="请输入用户(姓)名检索"> 
								<span class="input-group-addon btn-purple search-btn" id="queryInfo" style="cursor:pointer ;"> 
									<i class="fa fa-search"></i> GO
								</span>
							</div>
						</form>
					</div>
					<div class="col-md-2 col-md-offset-7">
						<button class="btn btn-sm btn-primary pull-right btn-pop" data-url='/user/add' data-width='515' data-height='525' data-title='添加用户' data-btn='false' style="margin-right:45px">
							<i class="fa fa-plus"></i> 添加用户
						</button>
					</div>
				</div>
			</th>
		</tr>
		<tr class="center">
			<th>序号</th>
			<th>用户名</th>
			<th>真实姓名</th>
			<th>注册时间</th>
			<th>状态</th>
			<th>操作</th>
		</tr>
	</thead>

	<tbody>
		#foreach($user in $obj.data.pager.entities )
		<tr>
			<td class="center">$!{user.id}</td>
			<td>$!{user.name}</td>
			<td>$!{user.realName}</td>
			<td>$!date.format('yyyy-MM-dd',$!{user.createTime})</td> 
			#if($!user.status == "ACTIVED")
				<td class="center">
					<button class="btn btn-success btn-xs">
						$!{user.status.name} <i class="fa fa-heart"></i>
					</button>
				</td> 
			#else
				<td class="center"><button class="btn btn-warning btn-xs">
					$!{user.status.name} <i class="fa fa-warning"></i>
				</button></td> 
			#end
			<td class="center">
				<div class="hidden-sm hidden-xs btn-group">
					<button class="btn btn-xs btn-success btn-pop" data-url='/user/info/$!{user.id}' data-width='425' data-height='325' data-title='用户 $!{user.realName} 详情' data-btn='false'>
						<i class="ace-icon fa fa-check bigger-120"></i>详情
					</button>
					
					<button class="btn btn-xs btn-warning btn-pop" data-url='/user/setRole/$!{user.id}' data-width='800' data-height='440' data-title='设置用户 $!{user.realName} 角色' data-btn='false'>
						<i class="ace-icon fa fa-fire  bigger-120"></i>设置角色
					</button>
					
					<button class="btn btn-xs btn-pink btn-pop" data-url='/user/setPermission/$!{user.id}' data-width='800' data-height='440' data-title='设置用户 $!{user.realName} 权限' data-btn='false'>
						<i class="ace-icon fa fa-bolt  bigger-120"></i>设置权限
					</button>

					<!-- button class="btn btn-xs btn-info btn-pop" data-url='/user/edit/$!{user.id}' data-width='425' data-height='500' data-title='编辑用户 $!{user.realName} 资料' data-btn='false'>
						<i class="ace-icon fa fa-pencil bigger-120"></i>编辑
					</button-->

					<button class="btn btn-xs btn-danger btn-delete" data-url='/user/delete' data-id='$!{user.id}'>
						<i class="ace-icon fa fa-trash-o bigger-120"></i>删除
					</button>
					
					#if($!user.status == "ACTIVED")
						<button class="btn btn-xs btn-purple" onclick="activeUser('$!user.id',false)">
							<i class="ace-icon fa fa-bell-slash bigger-120"></i>禁用
						</button>
					#else
						<button class="btn btn-xs btn-warning" onclick="activeUser('$!user.id',true)">
							<i class="ace-icon fa fa-flag bigger-120"></i>激活
						</button>
					#end
				</div>
			</td>
		</tr>
		#end
	</tbody>
	<tfoot>
		#if(${obj.data.pager.count} == 0)
		<tr>
			<td colspan="7" class="null-pager">没有符合条件的数据</td>
		</tr>
		#else
		<tr>
			<td colspan="7">
				<div class="pull-right">$!{obj.data.pager.pagerBar}</div>
			</td>
		</tr>
		#end
	</tfoot>
</table>
<script type="text/javascript">
	function activeUser(id, flag) {
		$.post(getRootPath() + "/user/toggleStatus", {
			id : id,
			status : flag ? 'ACTIVED' : 'DISABLED'
		}, function(result) {
			if (result.operationState == 'SUCCESS') {
				refresh();
			} else {
				showMessage(result.data.reason);
			}
		}, 'json');
	}
</script>